package som.simon.reactor;

import reactor.core.publisher.Flux;

import java.time.Duration;

public class RetryAndTimeOutMain {

    public static void main(String[] args) {
        
        Flux.range(1, 3)
                .delayElements(Duration.ofSeconds(3))
                .log()
                // 正对每一个流
                .timeout(Duration.ofSeconds(2))
                .retry(3)
                .onErrorReturn(SimonUtil.random())
                .map(SimonUtil::format)
                .subscribe(
                        v -> System.out.println("v = " + v),
                        err -> System.out.println("err = " + err),
                        () -> System.out.println("game over...")
                );

        SimonUtil.pause();

    }

}
